<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="author" content="esy">
    
    <meta name="description" content="esy">
    
    
    
    
    
    
    <title>分类模型的确定 | ESY</title>
    <link href="https://esyyes.github.io" rel="prefetch" />

    
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/aos.css">
<link rel="stylesheet" href="/css/style.css">

    
<script src="/js/jquery.min.js"></script>

    
<script src="/js/bootstrap.min.js"></script>

    
<script src="/js/aos.js"></script>

    
<script src="/js/highslide/highslide-full.min.js"></script>

    
<link rel="stylesheet" href="/js/highslide/highslide.css">

    <style type="text/css">
        @media (max-width: 768px) {
            body {
                background-color: #f0f0f0;
                background: url('/imgs/xsbg.gif');
                background-attachment: fixed;
            }
        }
    </style>
    
    <!--<script type="text/javascript">
      if (document.images) {
        var avatar = new Image();
        avatar.src = '/imgs/avatar.jpg'
        var previews = 'preview1.jpg,preview2.jpg,preview3.jpg,preview4.jpg'.split(',')
        var previewsPreLoad = []
        for(var i = 0; i < length; i++) {
          previewsPreLoad.push(new Image())
          previewsPreLoad[previewsPreLoad.length - 1].src = '/imgs/preview' + previews[i]
        }
      }
    </script>-->
<meta name="generator" content="Hexo 5.2.0"></head>
<body>
    <!-- 背景轮播图功能 -->
    <section class="hidden-xs">
    <ul class="cb-slideshow">
        <li><span>天若</span></li>
        <li><span>有情</span></li>
        <li><span>天亦老</span></li>
        <li><span>我为</span></li>
        <li><span>长者</span></li>
        <li><span>续一秒</span></li>
    </ul>
</section>
    <!-- 欧尼酱功能, 谁用谁知道 -->
    
    <div class="gal-menu gal-dropdown">
    <div class="circle" id="gal">
        <div class="ring">
            <a href="https://esyyes.github.io" class="menuItem" style="left: 50%; top: 15%;">首页</a>
            
            <a class="menuItem" style="left: 80.3109%; top: 32.5%;">下一页</a>
            
            <a href="/archives" class="menuItem" style="left: 80.3109%; top: 67.5%;">归档</a>
            <a href="/about" class="menuItem" style="left: 50%; top: 85%;">关于</a>
            <a href="/message" class="menuItem" style="left: 19.6891%; top: 67.5%;">留言板</a>

            
            <a class="menuItem" style="left: 19.6891%; top: 32.5%;">上一页</a>
            
        </div>
        <audio id="audio" src="/imgs/oni.mp3"></audio>
    </div>
</div>
    
    <header class="navbar navbar-inverse" id="gal-header">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed"
                    data-toggle="collapse" data-target=".bs-navbar-collapse"
                    aria-expanded="false">
                <span class="fa fa-lg fa-reorder"></span>
            </button>
            <a href="https://esyyes.github.io">
                
                <style>
                    #gal-header .navbar-brand {
                        height: 54px;
                        line-height: 24px;
                        font-size: 28px;
                        opacity: 1;
                        background-color: rgba(0,0,0,0);
                        text-shadow: 0 0 5px #fff,0 0 10px #fff,0 0 15px #fff,0 0 20px #228DFF,0 0 35px #228DFF,0 0 40px #228DFF,0 0 50px #228DFF,0 0 75px #228DFF;
                    }
                </style>
                <!-- 这里使用文字(navbar_text or config.title) -->
                <div class="navbar-brand">ESY</div>
                
            </a>
        </div>
        <div class="collapse navbar-collapse bs-navbar-collapse">
            <ul class="nav navbar-nav" id="menu-gal">
                
                
                <li class="">
                    <a href="/">
                        <i class="fa fa-home"></i>首页
                    </a>
                </li>
                
                
                
                <li class="">
                    <a href="/archives">
                        <i class="fa fa-archive"></i>归档
                    </a>
                </li>
                
                
                
                
                <li class="dropdown">
                    <!-- TODO 添加hover dropdown效果 -->
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"
                       aria-haspopup="true" aria-expanded="false" data-hover="dropdown">
                        <i class="fa fa-list"></i>分类
                    </a>
                    <ul class="dropdown-menu">
                        
                        
                        <li>
                            <a href="/categories/py-study/">py_study</a>
                        </li>
                        
                        <li>
                            <a href="/categories/nlp/">nlp</a>
                        </li>
                        
                        <li>
                            <a href="/categories/Graduation-work/">Graduation work</a>
                        </li>
                        
                        <li>
                            <a href="/categories/work/">work</a>
                        </li>
                        
                        <li>
                            <a href="/categories/hexo/">hexo</a>
                        </li>
                        
                        <li>
                            <a href="/categories/hexo%E5%AE%8C%E5%96%84/">-hexo完善</a>
                        </li>
                        
                        
                        <li>
                            <a href="/categories">...</a>
                        </li>
                        
                        
                    </ul>
                </li>
                
                
                
                
                
                <li class="dropdown">
                    <!-- TODO 添加hover dropdown效果 -->
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"
                       aria-haspopup="true" aria-expanded="false" data-hover="dropdown">
                        <i class="fa fa-tags"></i>标签
                    </a>
                    <ul class="dropdown-menu">
                        
                        
                        <li>
                            <a href="/tags/py-study/">py_study</a>
                        </li>
                        
                        <li>
                            <a href="/tags/nlp/">nlp</a>
                        </li>
                        
                        <li>
                            <a href="/tags/Graduation-work/">Graduation work</a>
                        </li>
                        
                        <li>
                            <a href="/tags/work/">work</a>
                        </li>
                        
                        <li>
                            <a href="/tags/hexo/">hexo</a>
                        </li>
                        
                        <li>
                            <a href="/tags/%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/">-个人博客搭建</a>
                        </li>
                        
                        
                        <li>
                            <a href="/tags">...</a>
                        </li>
                        
                        
                    </ul>
                </li>
                
                
                
                
                <li class="">
                    <a href="/about">
                        <i class="fa fa-user"></i>关于我
                    </a>
                </li>
                
                
            </ul>
        </div>
    </div>
</header>
    <div id="gal-body">
        <div class="container">
            <div class="row">
                <div class="col-md-8 gal-right" id="mainstay">
                    
<article class="article well article-body" id="article">
    <div class="breadcrumb">
        <i class="fa fa-home"></i>
        <a href="https://esyyes.github.io">ESY</a>
        >
        <span>分类模型的确定</span>
    </div>
    <!-- 大型设备详细文章 -->
    <div class="hidden-xs">
        <div class="title-article">
            <h1>
                <a href="/2020/08/31/python%20work/%E5%88%86%E7%B1%BB%E6%A8%A1%E5%9E%8B%E7%9A%84%E7%A1%AE%E5%AE%9A/">分类模型的确定</a>
            </h1>
        </div>
        <div class="tag-article">
            
            <span class="label label-gal">
                <i class="fa fa-tags"></i>
                
                <a href="/tags/work/">work</a>
                
            </span>
            
            <span class="label label-gal">
                <i class="fa fa-calendar"></i> 2020-08-31
            </span>
            
        </div>
    </div>
    <!-- 小型设备详细文章 -->
    <div class="visible-xs">
        <center>
            <div class="title-article">
                <h4>
                    <a href="/2020/08/31/python%20work/%E5%88%86%E7%B1%BB%E6%A8%A1%E5%9E%8B%E7%9A%84%E7%A1%AE%E5%AE%9A/">分类模型的确定</a>
                </h4>
            </div>
            <p>
                <i class="fa fa-calendar"></i> 2020-08-31
            </p>
            <p>
                
                <i class="fa fa-tags"></i>
                
                <a href="/tags/work/">work</a>
                
                
                
            </p>
        </center>
    </div>
    <div class="content-article">
        <h1 id="分类模型的确定"><a href="#分类模型的确定" class="headerlink" title="分类模型的确定"></a>分类模型的确定</h1><p>按照书中的完善分类器，和重新筛选分类器</p>
<h2 id="选择和训练分类模型"><a href="#选择和训练分类模型" class="headerlink" title="选择和训练分类模型"></a>选择和训练分类模型</h2><p> 分类问题的评价指标是准确率，那么回归算法的评价指标就是MSE，RMSE，MAE、R-Squared ，这几个是回归模型的。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> sklearn.metrics <span class="keyword">import</span> mean_squared_error <span class="comment">#均方误差</span></span><br><span class="line"><span class="keyword">from</span> sklearn.metrics <span class="keyword">import</span> mean_absolute_error <span class="comment">#平方绝对误差</span></span><br><span class="line"><span class="keyword">from</span> sklearn.metrics <span class="keyword">import</span> r2_score<span class="comment">#R square</span></span><br><span class="line"><span class="comment">#调用</span></span><br><span class="line">mean_squared_error(y_test,y_predict)</span><br><span class="line">mean_absolute_error(y_test,y_predict)</span><br><span class="line">r2_score(y_test,y_predict)</span><br></pre></td></tr></table></figure>

<ul>
<li>训练集（train set） —— 用于模型拟合的数据样本。</li>
<li>验证集（development set）—— 是模型训练过程中单独留出的样本集，它可以用于调整模型的超参数和用于对模型的能力进行初步评估。</li>
</ul>
<p>​         在神经网络中， 我们用验证数据集去寻找最优的网络深度（number of hidden layers)，或者决定反向传播算法的停止点或者<em>在神经网络中选择隐藏层神经元的数量；</em></p>
<p>​        在普通的机器学习中常用的交叉验证（Cross Validation) 就是把训练数据集本身再细分成不同的验证数据集去训练模型。</p>
<ul>
<li>测试集 —— 用来评估模最终模型的泛化能力。但不能作为调参、选择特征等算法相关的选择的依据。</li>
</ul>
<table>
<thead>
<tr>
<th align="left">类别</th>
<th align="left">验证集</th>
<th align="left">测试集</th>
</tr>
</thead>
<tbody><tr>
<td align="left">是否被训练到</td>
<td align="left">否</td>
<td align="left">否</td>
</tr>
<tr>
<td align="left">作用</td>
<td align="left">用于调超参数，监控模型是否发生过拟合（以决定是否停止训练）</td>
<td align="left">为了评估最终模型泛化能力</td>
</tr>
<tr>
<td align="left">使用次数</td>
<td align="left">多次使用，以不断调参</td>
<td align="left">仅仅一次使用</td>
</tr>
<tr>
<td align="left">缺陷</td>
<td align="left">模型在一次次重新手动调参并继续训练后所逼近的验证集，可能只代表一部分非训练集，导致最终训练好的模型泛化性能不够</td>
<td align="left">测试集为了具有泛化代表性，往往数据量比较大，测试一轮要很久，所以往往只取测试集的其中一小部分作为训练过程中的验证集</td>
</tr>
</tbody></table>
<h2 id="交叉验证"><a href="#交叉验证" class="headerlink" title="交叉验证"></a>交叉验证</h2><p>交叉验证算法的具体步骤如下</p>
<ol>
<li><p>随机将训练数据等分成k份，S1, S2, …, Sk。</p>
</li>
<li><p>对于每一个模型Mi，算法执行k次，每次选择一个Sj作为验证集，而其它作为训练集来训练模型Mi，把训练得到的模型在Sj上进行测试，这样一来，每次都会得到一个误差E，最后对k次得到的误差求平均，就可以得到模型Mi的泛化误差。</p>
</li>
<li><p><strong>算法选择具有最小泛化误差的模型作为最终模型，并且在整个训练集上再次训练该模型，从而得到最终的模型。</strong></p>
</li>
</ol>
<p>​        K折交叉验证，其主要 的目的是<strong>为了选择不同的模型类型（比如一次线性模型、非线性模型、）</strong>，而<strong>不是为了选择具体模型的具体参数</strong>。比如在BP神经网络中，其目的主要为了选择模型的层数、神经元的激活函数、每层模型的神经元个数（即所谓的超参数）。每一层网络神经元连接的最终权重是在模型选择（即K折交叉验证）之后，由全部的训练数据重新训练。 </p>
<p>目的在模型选择，而非模型训练调整参数。</p>
<p> <a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.cross_val_score.html">https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.cross_val_score.html</a> </p>
<p> <a target="_blank" rel="noopener" href="https://github.com/apachecn/hands-on-ml-zh/blob/master/docs/2.%E4%B8%80%E4%B8%AA%E5%AE%8C%E6%95%B4%E7%9A%84%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E9%A1%B9%E7%9B%AE.md">https://github.com/apachecn/hands-on-ml-zh/blob/master/docs/2.%E4%B8%80%E4%B8%AA%E5%AE%8C%E6%95%B4%E7%9A%84%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E9%A1%B9%E7%9B%AE.md</a> </p>
<h2 id="使用交叉验证去评估"><a href="#使用交叉验证去评估" class="headerlink" title="使用交叉验证去评估"></a>使用交叉验证去评估</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> warnings</span><br><span class="line"><span class="keyword">from</span> data_preprocessing <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">from</span> sklearn.model_selection <span class="keyword">import</span> train_test_split</span><br><span class="line"><span class="comment"># 均方误差</span></span><br><span class="line"><span class="keyword">from</span> sklearn.metrics <span class="keyword">import</span> mean_squared_error</span><br><span class="line"><span class="keyword">from</span> sklearn.linear_model <span class="keyword">import</span> LinearRegression</span><br><span class="line"><span class="keyword">from</span> sklearn.model_selection <span class="keyword">import</span> cross_val_score, cross_val_predict, permutation_test_score</span><br><span class="line"></span><br><span class="line"><span class="comment"># 忽略警告</span></span><br><span class="line">warnings.filterwarnings(<span class="string">&#x27;ignore&#x27;</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 提取分期为2时的17个特征</span></span><br><span class="line">feature_name = np.array(pd.read_excel(<span class="string">&#x27;F:/st_data/30-17个特征.xlsx&#x27;</span>)[<span class="string">&#x27;stage_2&#x27;</span>])[<span class="number">0</span>:<span class="number">17</span>]</span><br><span class="line"></span><br><span class="line"><span class="comment"># 读取ucddb库中的名字和AHI/SEFF</span></span><br><span class="line">data = pd.read_excel(<span class="string">&#x27;F:/py/py_sleep stage and apnea/data/&#x27;</span> + <span class="string">&#x27;ucddb&#x27;</span> + <span class="string">&#x27;_sleep_stages.xlsx&#x27;</span>)</span><br><span class="line">study_name = np.array(data[<span class="string">&#x27;data&#x27;</span>])</span><br><span class="line">data_AHI = np.array(data[<span class="string">&#x27;AHI&#x27;</span>])</span><br><span class="line">data_seff = np.array(data[<span class="string">&#x27;Seff&#x27;</span>])</span><br><span class="line"></span><br><span class="line"><span class="comment"># 读取ucddb库中的单个数据的全部特征</span></span><br><span class="line"><span class="keyword">for</span> text <span class="keyword">in</span> study_name[<span class="number">0</span>:<span class="number">1</span>]:</span><br><span class="line">    <span class="comment"># 读取ucddb库中的102个特征</span></span><br><span class="line">    features = pd.read_excel(<span class="string">&#x27;E:/MIT data/ucddb_feature/features_&#x27;</span> + <span class="string">&#x27;%s&#x27;</span> % text + <span class="string">&#x27;.xlsx&#x27;</span>)</span><br><span class="line">    <span class="comment"># 将获取的17个特征进行标准化和补缺失值</span></span><br><span class="line">    df = data_pre(pd.get_dummies(features.iloc[:, <span class="number">1</span>:])[feature_name])</span><br><span class="line">    <span class="comment"># 获取标签</span></span><br><span class="line">    labels = pd.read_excel(<span class="string">&#x27;E:/MIT data/ucddb_note/note_&#x27;</span> + <span class="string">&#x27;%s&#x27;</span> % text + <span class="string">&#x27;.xlsx&#x27;</span>)</span><br><span class="line">    tag = pd.get_dummies(labels.iloc[<span class="number">0</span>:<span class="built_in">len</span>(features), <span class="number">1</span>:<span class="number">2</span>])</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 分层抽样并按照7:3划分为训练集和测试集</span></span><br><span class="line">    X_train, X_test, y_train, y_test = train_test_split(df, tag, stratify=tag, test_size=<span class="number">0.3</span>)</span><br><span class="line">    lin_reg = LinearRegression()</span><br><span class="line">    lin_reg.fit(X_train, y_train)</span><br><span class="line">    pred_y = lin_reg.predict(X_test)</span><br><span class="line">    <span class="comment"># 均方误差</span></span><br><span class="line">    <span class="comment"># print(np.sqrt(mean_squared_error(y_test, pred_y)))</span></span><br><span class="line">    <span class="comment"># MSE均方误差</span></span><br><span class="line">    scores = cross_val_score(lin_reg, X_train, y_train, scoring=<span class="string">&#x27;neg_mean_squared_error&#x27;</span>, cv=<span class="number">10</span>)</span><br><span class="line">    rmse_scores = np.sqrt(-scores)</span><br></pre></td></tr></table></figure>



<p>Target is multiclass but average=’binary’. Please choose another average setting.</p>
<p> <a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_44436677/article/details/105985358">https://blog.csdn.net/weixin_44436677/article/details/105985358</a> </p>
<p>average参数定义了该指标的计算方法，<strong>二分类时average参数默认是binary</strong>；多分类时，可选参数有micro、macro、weighted和samples。</p>
<p><strong>None</strong>：返回每个班级的分数。否则，这将确定对数据执行的平均类型。</p>
<p><strong>binary</strong>：仅报告由指定的类的结果pos_label。仅当targets（y_{true,pred}）是二进制时才适用。</p>
<p><strong>micro</strong>：通过计算总真阳性，假阴性和误报来全球计算指标。也就是把所有的类放在一起算（具体到precision），然后把所有类的TP加和，再除以所有类的TP和FN的加和。因此micro方法下的<strong>precision和recall都等于accuracy。</strong></p>
<p><strong>macro</strong>：计算每个标签的指标，找出它们的未加权平均值。这不会考虑标签不平衡。也就是先分别求出每个类的precision再求其算术平均。</p>
<p><strong>weighted</strong>：计算每个标签的指标，并找到它们的平均值，按支持加权（每个标签的真实实例数）。这会改变“宏观”以解决标签不平衡问题; 它可能导致F分数不在精确度和召回之间。</p>
<p><strong>samples</strong>：计算每个实例的指标，并找出它们的平均值（仅对于不同的多标记分类有意义 accuracy_score）</p>
<p>若选用average=’micro’都等于准确率</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">print(<span class="string">f&#x27;<span class="subst">&#123;confusion_matrix(y_train, pre_train)&#125;</span>&#x27;</span>)</span><br><span class="line">precision = precision_score(y_train, pre_train, average=<span class="string">&#x27;macro&#x27;</span>)</span><br><span class="line">recall = recall_score(y_train, pre_train, average=<span class="string">&#x27;macro&#x27;</span>)</span><br><span class="line">F1 = f1_score(y_train, pre_train, average=<span class="string">&#x27;macro&#x27;</span>)</span><br><span class="line">print(<span class="string">f&#x27;精准度<span class="subst">&#123;precision&#125;</span>&#x27;</span>)</span><br><span class="line">print(<span class="string">f&#x27;召回率<span class="subst">&#123;recall&#125;</span>&#x27;</span>)</span><br><span class="line">print(<span class="string">f&#x27;f1_score<span class="subst">&#123;F1&#125;</span>&#x27;</span>)</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>现在都是训练，交叉验证什么的都不加入测试集。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line"><span class="comment"># @Time     : 2020/8/31</span></span><br><span class="line"><span class="comment"># @Author   : esy</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> warnings</span><br><span class="line"><span class="keyword">from</span> data_preprocessing <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">from</span> sklearn.model_selection <span class="keyword">import</span> train_test_split</span><br><span class="line"><span class="comment"># 均方误差</span></span><br><span class="line"><span class="keyword">from</span> sklearn.metrics <span class="keyword">import</span> mean_squared_error</span><br><span class="line"><span class="keyword">from</span> sklearn.linear_model <span class="keyword">import</span> LogisticRegression</span><br><span class="line"><span class="keyword">from</span> sklearn.model_selection <span class="keyword">import</span> cross_val_score, cross_val_predict, permutation_test_score</span><br><span class="line"><span class="keyword">from</span> sklearn.metrics <span class="keyword">import</span> accuracy_score, cohen_kappa_score, precision_score, recall_score, f1_score</span><br><span class="line"><span class="keyword">from</span> sklearn.metrics <span class="keyword">import</span> confusion_matrix</span><br><span class="line"></span><br><span class="line"><span class="comment"># 忽略警告</span></span><br><span class="line">warnings.filterwarnings(<span class="string">&#x27;ignore&#x27;</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 提取分期为2时的17个特征</span></span><br><span class="line">feature_name = np.array(pd.read_excel(<span class="string">&#x27;F:/st_data/30-17个特征.xlsx&#x27;</span>)[<span class="string">&#x27;stage_2&#x27;</span>])[<span class="number">0</span>:<span class="number">17</span>]</span><br><span class="line"></span><br><span class="line"><span class="comment"># 读取ucddb库中的名字和AHI/SEFF</span></span><br><span class="line">data = pd.read_excel(<span class="string">&#x27;F:/py/py_sleep stage and apnea/data/&#x27;</span> + <span class="string">&#x27;ucddb&#x27;</span> + <span class="string">&#x27;_sleep_stages.xlsx&#x27;</span>)</span><br><span class="line">study_name = np.array(data[<span class="string">&#x27;data&#x27;</span>])</span><br><span class="line">data_AHI = np.array(data[<span class="string">&#x27;AHI&#x27;</span>])</span><br><span class="line">data_seff = np.array(data[<span class="string">&#x27;Seff&#x27;</span>])</span><br><span class="line"></span><br><span class="line"><span class="comment"># 读取ucddb库中的单个数据的全部特征</span></span><br><span class="line"><span class="keyword">for</span> text <span class="keyword">in</span> study_name[<span class="number">0</span>:<span class="number">1</span>]:</span><br><span class="line">    <span class="comment"># 读取ucddb库中的102个特征</span></span><br><span class="line">    features = pd.read_excel(<span class="string">&#x27;E:/MIT data/ucddb_feature/features_&#x27;</span> + <span class="string">&#x27;%s&#x27;</span> % text + <span class="string">&#x27;.xlsx&#x27;</span>)</span><br><span class="line">    <span class="comment"># 将获取的17个特征进行标准化和补缺失值</span></span><br><span class="line">    df = data_pre(pd.get_dummies(features.iloc[:, <span class="number">1</span>:])[feature_name])</span><br><span class="line">    <span class="comment"># 获取标签</span></span><br><span class="line">    labels = pd.read_excel(<span class="string">&#x27;E:/MIT data/ucddb_note/note_&#x27;</span> + <span class="string">&#x27;%s&#x27;</span> % text + <span class="string">&#x27;.xlsx&#x27;</span>)</span><br><span class="line">    tag = pd.get_dummies(labels.iloc[<span class="number">0</span>:<span class="built_in">len</span>(features), <span class="number">1</span>:<span class="number">2</span>])</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 分层抽样并按照7:3划分为训练集和测试集</span></span><br><span class="line">    X_train, X_test, y_train, y_test = train_test_split(df, tag, stratify=tag, test_size=<span class="number">0.3</span>)</span><br><span class="line"></span><br><span class="line">    log_reg = LogisticRegression()</span><br><span class="line">    log_reg.fit(X_train, y_train)</span><br><span class="line">    pred_y = log_reg.predict(X_test)</span><br><span class="line">    <span class="comment"># 均方误差</span></span><br><span class="line">    <span class="comment"># print(np.sqrt(mean_squared_error(y_test, pred_y)))</span></span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">2</span>, <span class="number">15</span>):</span><br><span class="line">        scores = cross_val_score(log_reg, X_train, y_train, scoring=<span class="string">&#x27;accuracy&#x27;</span>, cv=i)</span><br><span class="line">        print(<span class="string">f&#x27;准率率的平均值<span class="subst">&#123;np.array(scores).mean()&#125;</span>&#x27;</span>)</span><br><span class="line">    print(<span class="string">f&#x27;准率率的标准差<span class="subst">&#123;np.array(scores).std()&#125;</span>&#x27;</span>)</span><br><span class="line">    pre_train = cross_val_predict(log_reg, X_train, y_train, cv=<span class="number">10</span>)</span><br><span class="line">    print(<span class="string">f&#x27;<span class="subst">&#123;confusion_matrix(y_train, pre_train)&#125;</span>&#x27;</span>)</span><br><span class="line">    precision = precision_score(y_train, pre_train, average=<span class="string">&#x27;macro&#x27;</span>)</span><br><span class="line">    recall = recall_score(y_train, pre_train, average=<span class="string">&#x27;macro&#x27;</span>)</span><br><span class="line">    F1 = f1_score(y_train, pre_train, average=<span class="string">&#x27;macro&#x27;</span>)</span><br><span class="line">    print(<span class="string">f&#x27;精准度<span class="subst">&#123;precision&#125;</span>&#x27;</span>)</span><br><span class="line">    print(<span class="string">f&#x27;召回率<span class="subst">&#123;recall&#125;</span>&#x27;</span>)</span><br><span class="line">    print(<span class="string">f&#x27;f1_score<span class="subst">&#123;F1&#125;</span>&#x27;</span>)</span><br></pre></td></tr></table></figure>



<p>已经开始了训练，所以下一步就是构建选择分类器。</p>
<p> <a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/model_evaluation.html#scoring-">https://scikit-learn.org/stable/modules/model_evaluation.html#scoring-</a> </p>
<table>
<thead>
<tr>
<th>Scoring</th>
<th>Function</th>
<th>Comment</th>
</tr>
</thead>
<tbody><tr>
<td><strong>Classification</strong></td>
<td></td>
<td></td>
</tr>
<tr>
<td>‘accuracy’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.accuracy_score.html#sklearn.metrics.accuracy_score"><code>metrics.accuracy_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘balanced_accuracy’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.balanced_accuracy_score.html#sklearn.metrics.balanced_accuracy_score"><code>metrics.balanced_accuracy_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘average_precision’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.average_precision_score.html#sklearn.metrics.average_precision_score"><code>metrics.average_precision_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘neg_brier_score’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.brier_score_loss.html#sklearn.metrics.brier_score_loss"><code>metrics.brier_score_loss</code></a></td>
<td></td>
</tr>
<tr>
<td>‘f1’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html#sklearn.metrics.f1_score"><code>metrics.f1_score</code></a></td>
<td>for binary targets</td>
</tr>
<tr>
<td>‘f1_micro’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html#sklearn.metrics.f1_score"><code>metrics.f1_score</code></a></td>
<td>micro-averaged</td>
</tr>
<tr>
<td>‘f1_macro’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html#sklearn.metrics.f1_score"><code>metrics.f1_score</code></a></td>
<td>macro-averaged</td>
</tr>
<tr>
<td>‘f1_weighted’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html#sklearn.metrics.f1_score"><code>metrics.f1_score</code></a></td>
<td>weighted average</td>
</tr>
<tr>
<td>‘f1_samples’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html#sklearn.metrics.f1_score"><code>metrics.f1_score</code></a></td>
<td>by multilabel sample</td>
</tr>
<tr>
<td>‘neg_log_loss’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.log_loss.html#sklearn.metrics.log_loss"><code>metrics.log_loss</code></a></td>
<td>requires <code>predict_proba</code> support</td>
</tr>
<tr>
<td>‘precision’ etc.</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_score.html#sklearn.metrics.precision_score"><code>metrics.precision_score</code></a></td>
<td>suffixes apply as with ‘f1’</td>
</tr>
<tr>
<td>‘recall’ etc.</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.recall_score.html#sklearn.metrics.recall_score"><code>metrics.recall_score</code></a></td>
<td>suffixes apply as with ‘f1’</td>
</tr>
<tr>
<td>‘jaccard’ etc.</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.jaccard_score.html#sklearn.metrics.jaccard_score"><code>metrics.jaccard_score</code></a></td>
<td>suffixes apply as with ‘f1’</td>
</tr>
<tr>
<td>‘roc_auc’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_auc_score.html#sklearn.metrics.roc_auc_score"><code>metrics.roc_auc_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘roc_auc_ovr’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_auc_score.html#sklearn.metrics.roc_auc_score"><code>metrics.roc_auc_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘roc_auc_ovo’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_auc_score.html#sklearn.metrics.roc_auc_score"><code>metrics.roc_auc_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘roc_auc_ovr_weighted’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_auc_score.html#sklearn.metrics.roc_auc_score"><code>metrics.roc_auc_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘roc_auc_ovo_weighted’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_auc_score.html#sklearn.metrics.roc_auc_score"><code>metrics.roc_auc_score</code></a></td>
<td></td>
</tr>
<tr>
<td><strong>Clustering</strong></td>
<td></td>
<td></td>
</tr>
<tr>
<td>‘adjusted_mutual_info_score’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.adjusted_mutual_info_score.html#sklearn.metrics.adjusted_mutual_info_score"><code>metrics.adjusted_mutual_info_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘adjusted_rand_score’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.adjusted_rand_score.html#sklearn.metrics.adjusted_rand_score"><code>metrics.adjusted_rand_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘completeness_score’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.completeness_score.html#sklearn.metrics.completeness_score"><code>metrics.completeness_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘fowlkes_mallows_score’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.fowlkes_mallows_score.html#sklearn.metrics.fowlkes_mallows_score"><code>metrics.fowlkes_mallows_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘homogeneity_score’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.homogeneity_score.html#sklearn.metrics.homogeneity_score"><code>metrics.homogeneity_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘mutual_info_score’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mutual_info_score.html#sklearn.metrics.mutual_info_score"><code>metrics.mutual_info_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘normalized_mutual_info_score’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.normalized_mutual_info_score.html#sklearn.metrics.normalized_mutual_info_score"><code>metrics.normalized_mutual_info_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘v_measure_score’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.v_measure_score.html#sklearn.metrics.v_measure_score"><code>metrics.v_measure_score</code></a></td>
<td></td>
</tr>
<tr>
<td><strong>Regression</strong></td>
<td></td>
<td></td>
</tr>
<tr>
<td>‘explained_variance’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.explained_variance_score.html#sklearn.metrics.explained_variance_score"><code>metrics.explained_variance_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘max_error’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.max_error.html#sklearn.metrics.max_error"><code>metrics.max_error</code></a></td>
<td></td>
</tr>
<tr>
<td>‘neg_mean_absolute_error’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_absolute_error.html#sklearn.metrics.mean_absolute_error"><code>metrics.mean_absolute_error</code></a></td>
<td></td>
</tr>
<tr>
<td>‘neg_mean_squared_error’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_error.html#sklearn.metrics.mean_squared_error"><code>metrics.mean_squared_error</code></a></td>
<td></td>
</tr>
<tr>
<td>‘neg_root_mean_squared_error’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_error.html#sklearn.metrics.mean_squared_error"><code>metrics.mean_squared_error</code></a></td>
<td></td>
</tr>
<tr>
<td>‘neg_mean_squared_log_error’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_log_error.html#sklearn.metrics.mean_squared_log_error"><code>metrics.mean_squared_log_error</code></a></td>
<td></td>
</tr>
<tr>
<td>‘neg_median_absolute_error’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.median_absolute_error.html#sklearn.metrics.median_absolute_error"><code>metrics.median_absolute_error</code></a></td>
<td></td>
</tr>
<tr>
<td>‘r2’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.r2_score.html#sklearn.metrics.r2_score"><code>metrics.r2_score</code></a></td>
<td></td>
</tr>
<tr>
<td>‘neg_mean_poisson_deviance’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_poisson_deviance.html#sklearn.metrics.mean_poisson_deviance"><code>metrics.mean_poisson_deviance</code></a></td>
<td></td>
</tr>
<tr>
<td>‘neg_mean_gamma_deviance’</td>
<td><a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_gamma_deviance.html#sklearn.metrics.mean_gamma_deviance"><code>metrics.mean_gamma_deviance</code></a></td>
<td></td>
</tr>
</tbody></table>
<p> 此实现不适用于大规模数据应用。 特别是 scikit-learn 不支持 GPU。如果想要提高运行速度并使用基于 GPU 的实现以及为构建深度学习架构提供更多灵活性的框架，请参阅 <a target="_blank" rel="noopener" href="https://scikit-learn.org/stable/related_projects.html#related-projects">Related Projects</a> 。 </p>
<p><img src="https://pic.rmb.bdstatic.com/c91adf54fa1b5b43a523664167cdc2ab.gif"></p>

    </div>
</article>


                </div>
                <aside class="col-md-4 gal-left" id="sidebar">
    <!-- 此为sidebar的搜索框, 非搜索结果页面 -->
<aside id="sidebar-search">
    <div class="search hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <form class="form-inline clearfix" id="search-form" method="get"
              action="/search/index.html">
            <input type="text" name="s" class="form-control" id="searchInput" placeholder="搜索文章~" autocomplete="off">
            <button class="btn btn-danger btn-gal" type="submit">
                <i class="fa fa-search"></i>
            </button>
        </form>
    </div>
</aside>
    <aside id="sidebar-author">
    <div class="panel panel-gal" data-aos="flip-right" data-aos-duration="3000">
        <div class="panel-heading" style="text-align: center">
            <i class="fa fa-quote-left"></i>
            esy
            <i class="fa fa-quote-right"></i>
        </div>
        <div class="author-panel text-center">
            <img src="/imgs/avatar.jpg" width="140" height="140"
                 alt="个人头像" class="author-image">
            <p class="author-description"><p>esy</p>
</p>
        </div>
    </div>
</aside>
    
    <aside id="sidebar-recent_comments">
    <div class="panel panel-gal recent hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <div class="panel-heading">
            <i class="fa fa-comments"></i>
            最新评论
            <i class="fa fa-times-circle panel-remove"></i>
            <i class="fa fa-chevron-circle-up panel-toggle"></i>
        </div>
        <ul class="list-group list-group-flush"></ul>
    </div>
</aside>
    
    <!-- 要配置好leancloud才能开启此小工具 -->
    
    
    <aside id="sidebar-recent_posts">
    <div class="panel panel-gal recent hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <div class="panel-heading">
            <i class="fa fa-refresh"></i>
            近期文章
            <i class="fa fa-times-circle panel-remove"></i>
            <i class="fa fa-chevron-circle-up panel-toggle"></i>
        </div>
        <ul class="list-group list-group-flush">
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/11/05/python%20work/%E6%9C%80%E5%B0%8F%E4%BA%8C%E4%B9%98%E6%B3%95/">最小二乘法</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/11/05/python%20work/%E7%BB%9F%E8%AE%A1%E5%AD%A6%E4%B9%A0-%E7%AC%AC%E4%B8%80%E7%AB%A0/">统计学习--第一章</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/11/04/python%20work/hello-world/">Hello World</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/11/03/python%20work/%E5%88%86%E7%B1%BB%E6%A8%A1%E5%9E%8B%E7%9A%84%E8%AF%84%E4%BC%B0%E6%8C%87%E6%A0%87/">分类模型的评估指标</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/10/21/python%20work/10-21-%E7%88%AC%E8%99%AB%E5%9F%BA%E7%A1%80/">10-21 爬虫基础</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/CRF%E7%9A%84%E6%95%B4%E4%BD%93%E6%B5%81%E7%A8%8B%E7%BB%93%E6%9E%9C/">CRF的整体流程结果</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/nlp-crf%E6%A8%A1%E5%9E%8B/">nlp_crf模型</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/%E6%95%B0%E5%AD%A6%E5%BB%BA%E6%A8%A1%E9%97%AE%E9%A2%983/">数学建模问题3</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/%E6%95%B0%E5%AD%A6%E5%BB%BA%E6%A8%A1%E9%97%AE%E9%A2%982/">数学建模问题2</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/09/25/python%20work/%E6%95%B0%E5%AD%A6%E5%BB%BA%E6%A8%A1%E9%97%AE%E9%A2%981/">数学建模问题1</a>
                </span>
            </li>
            
        </ul>
    </div>
</aside>
    
    
    <aside id="sidebar-rand_posts">
    <div class="panel panel-gal recent hidden-xs" data-aos="fade-up" data-aos-duration="2000">
        <div class="panel-heading">
            <i class="fa fa-refresh"></i>
            随机文章
            <i class="fa fa-times-circle panel-remove"></i>
            <i class="fa fa-chevron-circle-up panel-toggle"></i>
        </div>
        <ul class="list-group list-group-flush">
            
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/06/08/python%20work/ECG-RR%E9%97%B4%E6%9C%9F%E9%A2%84%E5%A4%84%E7%90%86/">ECG_RR间期预处理</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/07/22/python%20work/chatbot-sorry%E7%AF%87/">chatbot_sorry篇</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2019/11/24/python%20work/pyhon%E5%9F%BA%E7%A1%80-%E5%87%BD%E6%95%B0/">pyhon基础--函数</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/05/05/python%20work/python-opencv%E5%9F%BA%E7%A1%80%E5%85%A5%E9%97%A8/">python-opencv基础入门</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2019/12/26/python%20work/python%E8%B0%83%E7%94%A8wfdb/">LV-3</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/11/03/python%20work/%E5%88%86%E7%B1%BB%E6%A8%A1%E5%9E%8B%E7%9A%84%E8%AF%84%E4%BC%B0%E6%8C%87%E6%A0%87/">分类模型的评估指标</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/08/08/python%20work/%E5%9C%A8UI%E7%95%8C%E9%9D%A2%E4%B8%AD%E5%8A%A0%E5%85%A5%E6%97%B6%E9%97%B4%E6%B5%8B%E8%AF%95/">在UI界面中加入时间测试</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/07/08/python%20work/%E7%8A%B6%E6%80%81%E4%B8%BA3%E6%97%B6%E7%9A%84%E8%AE%BE%E5%AE%9A/">状态为3时的设定</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/06/24/python%20work/%E7%BB%98%E5%88%B6%E7%89%B9%E5%BE%81%E9%87%8D%E8%A6%81%E5%BA%A6%E7%AD%9B%E9%80%89%E7%BB%93%E6%9E%9C/">绘制特征重要度筛选结果</a>
                </span>
            </li>
            
            <li class="list-group-item">
                <span class="post-title">
                    <a href="/2020/08/20/python%20work/%E9%87%8D%E6%96%B0%E6%9E%84%E5%BB%BAslpdb%E4%B8%AD%E7%9A%84%E7%89%B9%E5%BE%81%E5%92%8C%E6%A0%87%E7%AD%BE/">重新构建slpdb中的特征和标签</a>
                </span>
            </li>
            
        </ul>
    </div>
</aside>
    
    
    <aside id="gal-sets">
        <div class="panel panel-gal hidden-xs" data-aos="fade-up" data-aos-duration="2000">
            <ul class="nav nav-pills pills-gal">

                
                <li>
                    <a href="/2020/08/31/python%20work/%E5%88%86%E7%B1%BB%E6%A8%A1%E5%9E%8B%E7%9A%84%E7%A1%AE%E5%AE%9A/index.html#sidebar-tags" data-toggle="tab" id="tags-tab">热门标签</a>
                </li>
                
                
                <li>
                    <a href="/2020/08/31/python%20work/%E5%88%86%E7%B1%BB%E6%A8%A1%E5%9E%8B%E7%9A%84%E7%A1%AE%E5%AE%9A/index.html#sidebar-friend-links" data-toggle="tab" id="friend-links-tab">友情链接</a>
                </li>
                
                
                <li>
                    <a href="/2020/08/31/python%20work/%E5%88%86%E7%B1%BB%E6%A8%A1%E5%9E%8B%E7%9A%84%E7%A1%AE%E5%AE%9A/index.html#sidebar-links" data-toggle="tab" id="links-tab">个人链接</a>
                </li>
                
            </ul>
            <div class="tab-content">
                
                <div class="cloud-tags tab-pane nav bs-sidenav fade" id="sidebar-tags">
    
    <a href="/tags/py-study/" style="font-size: 19.029203242137925px;" class="tag-cloud-link">py_study</a>
    
    <a href="/tags/nlp/" style="font-size: 13.452232631978008px;" class="tag-cloud-link">nlp</a>
    
    <a href="/tags/Graduation-work/" style="font-size: 10.870272111881487px;" class="tag-cloud-link">Graduation work</a>
    
    <a href="/tags/work/" style="font-size: 11.034971768964311px;" class="tag-cloud-link">work</a>
    
    <a href="/tags/hexo/" style="font-size: 14.72373573646033px;" class="tag-cloud-link">hexo</a>
    
    <a href="/tags/%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/" style="font-size: 12.867294774070391px;" class="tag-cloud-link">-个人博客搭建</a>
    
    <a href="/tags/malab-%E6%AF%95%E4%B8%9A/" style="font-size: 13.615641054216077px;" class="tag-cloud-link">-malab -毕业</a>
    
    <a href="/tags/python-%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD/" style="font-size: 16.986276654556814px;" class="tag-cloud-link">-python -人工智能</a>
    
    <a href="/tags/python/" style="font-size: 8.044638800658834px;" class="tag-cloud-link">python</a>
    
    <a href="/tags/python/" style="font-size: 12.06900965534459px;" class="tag-cloud-link">-python</a>
    
    <a href="/tags/mathematical-modeling/" style="font-size: 8.513003391020556px;" class="tag-cloud-link">mathematical modeling</a>
    
    <a href="/tags/statistical-learning/" style="font-size: 12.074194015001869px;" class="tag-cloud-link">statistical learning</a>
    
</div>
                
                
                <div class="friend-links tab-pane nav bs-sidenav fade" id="sidebar-friend-links">
    
    <li>
        <a href="http://kdays.net/days/" target="_blank">KDays Forum</a>
    </li>
    
    <li>
        <a href="http://www.gal123.com/" target="_blank">绅士导航♂</a>
    </li>
    
    <li>
        <a href="http://www.moe123.com/" target="_blank">萌导航</a>
    </li>
    
</div>
                
                
                <div class="links tab-pane nav bs-sidenav fade" id="sidebar-links">
    
    <li>
        <a href="https://github.com/ZEROKISEKI/" target="_blank">Github</a>
    </li>
    
    <li>
        <a href="https://coding.net/u/SORA1" target="_blank">Coding</a>
    </li>
    
    <li>
        <a href="https://www.zhihu.com/people/aonosora/activities" target="_blank">知乎</a>
    </li>
    
</div>
                
            </div>
        </div>
    </aside>
    
</aside>
            </div>
        </div>
    </div>
    <footer id="gal-footer">
    <div class="container">
        Copyright © 2018 esy Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>.&nbsp;Theme by <a href="https://github.com/ZEROKISEKI" target="_blank">AONOSORA</a>
    </div>
</footer>

<!-- 回到顶端 -->
<div id="gal-gotop">
    <i class="fa fa-angle-up"></i>
</div>
</body>

<script src="/js/activate-power-mode.js"></script>

<script>

    // 配置highslide
	hs.graphicsDir = '/js/highslide/graphics/'
    hs.outlineType = "rounded-white";
    hs.dimmingOpacity = 0.8;
    hs.outlineWhileAnimating = true;
    hs.showCredits = false;
    hs.captionEval = "this.thumb.alt";
    hs.numberPosition = "caption";
    hs.align = "center";
    hs.transitions = ["expand", "crossfade"];
    hs.lang.number = '共%2张图, 当前是第%1张';
    hs.addSlideshow({
      interval: 5000,
      repeat: true,
      useControls: true,
      fixedControls: "fit",
      overlayOptions: {
        opacity: 0.75,
        position: "bottom center",
        hideOnMouseOut: true
      }
    })

    // 初始化aos
    AOS.init({
      duration: 1000,
      delay: 0,
      easing: 'ease-out-back'
    });

</script>
<script>
	POWERMODE.colorful = 'true';    // make power mode colorful
	POWERMODE.shake = 'true';       // turn off shake
	// TODO 这里根据具体情况修改
	document.body.addEventListener('input', POWERMODE);
</script>
<script>
    window.slideConfig = {
      prefix: '/imgs/slide/background',
      ext: 'jpg',
      maxCount: '6'
    }
</script>

<script src="/js/hs.js"></script>
<script src="/js/blog.js"></script>



<script src="/js/oni.js"></script>




</html>